home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3564 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: A question about STRING.
  5. Date: Mon, 29 Jan 96 22:56:41 GMT
  6. Organization: none
  7. Message-ID: <822956201snz@genesis.demon.co.uk>
  8. References: <4e0akh$853@erinews.ericsson.se> <4ej6tc$svf@news.acns.nwu.edu>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4ej6tc$svf@news.acns.nwu.edu>
  15.            muzaffar@casbah.acns.nwu.edu "Usman Muzaffar" writes:
  16.  
  17. >>In my program, there is a variable MUTLI_RECORDS defined as char, which has a
  18. >>typical string as following:
  19. >>
  20. >>1,0,a,map010017000802532236,1,pp,0.2,1,0,map010017000802532236,acc,1,0. ...
  21. >>
  22. >>In fact, this string contains many records. Each record contains seven
  23. > columns.
  24. >>The columns in each record are seperated by the comma ','. Each record is 
  25. >>terminated by a full stop '.'.
  26.  
  27. >Doesn't the strtok function in the standard library do just this for you?
  28. >Split up an incoming string into tokens, and assign one to each. 
  29. >Although, a simple while loop could do the trick, too.
  30.  
  31. Maybe, maybe not - it depends on what exactly is wanted. strtok treats
  32. adjacent separator characters as a single separator (useful for dealing
  33. with, for example, whitespace) so 'tokens' must have a nonzero length.
  34. With a strict file format each separator character is typically significant
  35. and if that is the case (adjacent separators are possible) then strtok is
  36. not suitable.
  37.  
  38. -- 
  39. -----------------------------------------
  40. Lawrence Kirby | fred@genesis.demon.co.uk
  41. Wilts, England | 70734.126@compuserve.com
  42. -----------------------------------------
  43.